{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    <ul class="nav nav-tabs">
        <li ><a href="{php echo createWebUrl('shangjia');}">可用商家列表</a></li>
        <li ><a href="{php echo createWebUrl('shangjia', array('action' =>2));}">暂停商家列表</a></li>
        <li {if $action == 3}class="active"{/if}><a href="{php echo createWebUrl('shangjia', array('action' =>3));}">商家报名信息</a></li>
        <li ><a href="{php echo createWebUrl('shangjiaadd');}">新增商家</a></li>
        <li {if $action == 4}class="active"{/if}><a href="{php echo createWebUrl('shangjia', array('action' =>4));}">分组管理</a></li>
        <li ><a href="{php echo createWebUrlPlugin('sjmulitverify.index',array('themeid'=>$themeid));}">商家产品列表</a></li>
        <li class="active"><a href="">商家产品编辑</a></li>
    </ul>
    <div class="panel panel-default" role="tabpanel">
        <div class="panel-heading">基本信息</div>
        <div class="panel-body">
            <form action="" method="post" class="form-horizontal" role="form" name="form2" id="form2">
                <input type="hidden" name="id" value="{$item['id']}"/>
                <input type="hidden" name="themeid" value="{$themeid}"/>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>所属商家</label>
                    <div class="col-sm-8 col-xs-12">
                        <select class="form-control" name="shangjiaid">
                            <option value="0" {if empty($item['shangjiaid']) }selected="selected"{/if}>----------请选择商家----------</option>
                            {loop $shangjia  $val}
                            <option value="{$val['id']}" {if $item['shangjiaid'] == $val['id'] }selected="selected"{/if}>{$val['id']}-{$val['name']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>名称</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control"  placeholder="" name="name"  value="{$item['name']}">
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">状态</label>
                    <div class="col-sm-8 col-xs-12">
                        <label class="radio-inline">
                            <input name="status" value="1" {if $item['status']==1 || !$item} checked="checked"{/if} type="radio"> 上架
                        </label>
                        <label class="radio-inline">
                            <input name="status" value="0" {if $item && $item['status']==0} checked="checked"{/if} type="radio"> 下架
                        </label>
                    </div>
                </div>

                <div class="form-group" id="sub_upload" >
                    <div class="col-sm-12">
                        <input name="submit" onclick="addOrEditItem()" id="btnConfirm" type="button" value="提交" class="btn btn-primary col-lg-2">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


<script type="text/javascript">

    //新增\修改奖品 提交数据
    function addOrEditItem() {
        // if ($("#show_sort").val().length>2){
        //     layer.msg('展示排名，请设置两位数以内的排序值');
        //     return;
        // }
        let postUrl = "{php echo createWebUrlPlugin('sjmulitverify.add',array('themeid'=>$themeid));}";
        let success_redirect = "{php echo createWebUrlPlugin('sjmulitverify.index',array('themeid'=>$themeid));}";
        let formData = $("#form2").serialize();
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:formData,
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.msg)
                }else{
                    layer.msg(result.msg);
                    window.location.href = success_redirect;
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    }
</script>
